//
//  UIColor+Extension.m
//  QueueUpApp
//
//  Created by zyz on 16/3/10.
//  Copyright © 2016年 hfxz. All rights reserved.
//

#import "UIColor+Extension.h"

@implementation UIColor (Extension)

+ (UIColor*) colorWithHex:(long)hexColor;
{
    return [self colorWithHex:hexColor alpha:1.];
}

+ (UIColor *)colorWithHex:(long)hexColor alpha:(float)opacity
{
    float red = ((float)((hexColor & 0xFF0000) >> 16))/255.0;
    float green = ((float)((hexColor & 0xFF00) >> 8))/255.0;
    float blue = ((float)(hexColor & 0xFF))/255.0;
    return [UIColor colorWithRed:red green:green blue:blue alpha:opacity];
}

+ (UIColor *)colorWithR:(float)r G:(float)g B:(float)b
{
    return [self colorWithR:r G:g B:b alpha:1.f];
}

+ (UIColor *)colorWithR:(float)r G:(float)g B:(float)b alpha:(float)opactiy
{
    return [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:opactiy];
}

+ (UIColor *)randomColor
{
    return [self colorWithR:arc4random() % 255 G:arc4random() % 255 B:arc4random() % 255];
}
@end
